<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //需求：计算1-100奇数和
      var sum = 0;
      for (var i = 1; i <= 100; i = i + 2) {
        sum = sum + i;
      }

      /*var i = 1;
      var sum = 0;
      for (;;) { //死循环
        if(i<=100){
          sum = sum + i;
          i+=2; // i=i+2;
        }
        else{
            break;//跳出循环
        }
      }*/
      document.write("1-100奇数和为" + sum + "<br/>");
    </script>
  </body>
</html>
